﻿using System;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Logging;

namespace CrawlServiceCore.Crawl
{
    /// <summary>
    /// Implementation of IHandleCrawlInformation which writes the information to the Log File.
    /// </summary>
    public class LogHandler : IHandleCrawlInformation
    {
        public void SendInformation(string userName, string description, string url)
        {
            LogWriter log = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
            try
            {
                log.Write(string.Format("\n\r Name - {0} \n\r Doc - {1} \n\r Url- {2}", userName, description, url));
            }
            catch (Exception ex)
            {
                log.Write("Error from ConsoleHandler::SendInformation stack: " + ex.ToString(), "Error");
            }
        }
    }
}
